<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>小罗后台管理系统</title>
    <link rel="stylesheet" href="/assets/layui/css/layui.css">
</head>

<body>
    <div class="layui-layout layui-layout-admin">
        <!-- 导入公共页面 -->
        {{ include "./common/header.html" }}

        <!-- 导入公共页面 -->
        {{ include "./common/side.html" }}

        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div style="padding: 15px;">
                <h1 style="margin: 10px 60px;">添加分类</h1>
                <form class="layui-form" id="cateForm" lay-filter="example">
                    <div class="layui-form-item">
                        <label class="layui-form-label">分类名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="cate_name" lay-verify="cate_name" autocomplete="off" placeholder="分类名"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">显示隐藏</label>
                        <div class="layui-input-block">
                            <input type="radio" name="orderBy" value="0" title="隐藏" >
                            <input type="radio" name="orderBy" value="1" title="显示">
                        </div>
                    </div>
                

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="button" class="layui-btn"  id="submitForm">立即提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

    </div>
</body>

<script src="/assets/layui/layui.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<script src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.2/moment.min.js"></script>
<script>
$("#submitForm").on('click',async (data)=>{
       const formData = new FormData( $("#cateForm")[0] )
       const {code,message} = await $.ajax({
           url:"/addCateDate",
           type: 'post',
           data:formData,
           contentType:false,
           processData:false
       })
       layer.msg(message)
       if(code === 0){
        location.href = '/category'
       }
      
       
   })

</script>
</html>